package com.bdqn.vueboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.vueboot.entity.Furniture;
import com.bdqn.vueboot.entity.Mail;
import com.bdqn.vueboot.service.MailService;
import com.bdqn.vueboot.mapper.MailMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 *
 */
@Service
public class MailServiceImpl extends ServiceImpl<MailMapper, Mail>
        implements MailService {
    @Resource
    MailMapper mailMapper;

    @Override
    public IPage<Mail> allmodifyListBiz(Integer mailType, String mailStaticDate, String mailStatic, Integer indexPage, Integer limit) {
        Page<Mail> page = new Page<Mail>(indexPage, limit);
        return mailMapper.allmodifyList(mailType, mailStaticDate, mailStatic, page);
    }

    @Override
    public int seva(Mail mail) {
        if (mail.getMailId() == null || mail.getMailId() == 0) {
            return mailMapper.insert(mail);
        } else {
            return mailMapper.updateById(mail);
        }
    }

    @Override
    public int delIsDeleByMailId(Long mailId, Long isDel) {
        Mail mail = new Mail();
        mail.setMailId(mailId);
        mail.setIsDel(isDel);
        return mailMapper.updateById(mail);
    }

    @Override
    public int sevaAudit(String mailStatic, Long mailId) {
        UpdateWrapper<Mail> updateWrapper = new UpdateWrapper();
        updateWrapper.eq("mail_Id", mailId);
        Mail mail = new Mail();
        mail.setMailStatic(mailStatic);
        return mailMapper.update(mail, updateWrapper);
    }
}




